package juc.c_020;/*
   Talk is cheap. Show me the code.
 */

import java.util.concurrent.TimeUnit;

/**
 * @Description
 * @Date 2021/6/7
 * @Author liudl
 */
public class T01_ReentrancLock {
    private synchronized void m1(){
        for (int i = 0; i < 5; i++) {
            System.out.println(i);
            try {
                TimeUnit.SECONDS.sleep(1);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            if (i == 2) {
                m2();
            }
        }
    }
    private synchronized void m2() {
        System.out.println("m2.......");
    }

    public static void main(String[] args) throws InterruptedException {
        T01_ReentrancLock o = new T01_ReentrancLock();
        new Thread(o::m1).start();
        TimeUnit.SECONDS.sleep(1);
//        new Thread(o::m2).start();
    }
}
